package com.liuyfly.leetcode.study;

import com.liuyfly.leetcode.util.LeetcodeUtil;
import lombok.extern.slf4j.Slf4j;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author liuyangfang at 2022-09-07 14:04
 */
@Slf4j
public class MyMultiply {

    public static double myMultiply(int x, int y) {
        if (y == 1) {
            return x;
        }
        if (y==-1){
            return x*-1;
        }
        int middle = y /2;
        if (y % 2 == 0) {
            return myMultiply(x + x, middle);
        } else {
            return y>0?(x + myMultiply(x + x, middle)):(x*-1 + myMultiply(x + x, middle));
        }
    }

    public static void main(String[] args) {
//        log.info("result:{}", myMultiply(304, -3));
        List<String> list = new ArrayList<>();
        list.add("A1");
        list.add("A2");
        list.add("A1");
        list.add("A2");
        list.add("A3");
        List<String> list2 = list.stream().distinct().collect(Collectors.toList());
        LeetcodeUtil.printList(list2);
        BigInteger bigInteger = new BigInteger("12312312312391242348123648273741");
        System.out.println(bigInteger);
    }
}
